<!DOCTYPE html>
<html>
<head>
<title>{$eju.field.info.fang_title}{$eju.field.info.ask_title}-问答中心</title>
<meta name="renderer" content="webkit" />
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0,user-scalable=0,minimal-ui" />
<link href="{eju:global name='web_cmspath' /}/favicon.ico" rel="shortcut icon" type="image/x-icon" />
<meta name="applicable-device"content="mobile">
{eju:static file="ask/skin/css/ask.css" /}

{eju:static file="/public/static/common/js/jquery.min.js"/}
{eju:static file="/public/plugins/layer-v3.1.0/layer.js"/}
{eju:static file="skin/css/public.css" /}
{eju:static file="skin/css/color.css" /}
{eju:static file="ask/skin/css/pusk.css" /}
{eju:static file="ask/skin/css/ask.css" /}
</head>

<body>
<!-- 头部 --> 
{eju:include file="header.htm"/} 
<!-- END -->
<div class="search flexbox ask_top" id="searchbox" style="border-bottom:none;">
  <!--<div class="searbox" id="new_searchtext">-->
    <!--<div class="inputbox" id="wapasksy_D01_05"> <a class="input" href="javascript:void(0);" ><i></i>请输入您的问题</a> </div>-->
  <!--</div>-->
  <!--<a class="questionbtn" id="wapasksy_D01_06">常见问题<i></i></a>-->
</div>
<div class="main ">
  <section class="crumb pdX20"> <a href="{eju:global name='web_cmsurl' /}" class="f999">首页</a> > <a href="{$eju.field.NewDateUrl}" class="f999">问答</a> > {$eju.field.info.ask_title} </section>

  <section class="pdX20 mBox">
    <div class="answerMylist">
      <ul>
        <li>
          <h2 class="">{$eju.field.info.ask_title}</h2>
          <div class="askAnShare bt mt14">
            <div class="s1">
              <p>提问者：{$eju.field.info.username}</p>
              <p class="mt10">发布于{$eju.field.info.add_time|MyDate="Y-m-d H:i:s",###}</p>
            </div>
            <div class="s2"  id="answer_click">
              <a href="javascript:void(0);"  id="answer_click_01" onclick="show_answer()" class="tiwen mgX10"><i></i>回答</a>
            </div>
          </div>
          <div id="answer_edit" class="answer-edit"  style="display: none;">
            {eju:empty name="$canAnswer"}
            <div id="container" class="edui-default">
              <div class="edui-editor edui-default" style="text-indent: 0.5em; height:40px; z-index: 5; border:1px solid #ff6600; padding-top: 6px;">^-^我来说两句，请先
                <a href="{:url('user/Users/login')}" style="color: red;">登录</a>
                <em>·</em>
                <a href="{:url('user/Users/reg')}" style="color: red;">注册</a>
              </div>
            </div>
            {eju:else/}
            <textarea placeholder="请输入答案" id="ask_content" name="ask_content" ></textarea>
            <a href="javascript:void(0);" style="float: right;width: 120px;height: 33px;line-height: 33px;text-align: center;color:#fff;font-size: 14px;border-radius: 4px;background: #ff5200;margin-top: 10px;" class="i-submit-btn"  data-url="{$eju.field.AddAnswerUrl}" onclick="return answer_submit(this);" id="answersubmit">提交回答</a>
            <span style="float: left;margin: 10px 10px 0 0;cursor: pointer;color:#333;" onclick="hide_answer()" class="btn-toggle">收起<i class="btn-upjt btn-downjt"></i> </span>
            {/eju:empty}
            <div class="clear"></div>
          </div>
        </li>
      </ul>
    </div>
  </section>
  {eju:static file="/public/plugins/Ueditor/ueditor.config.js"/}
  {eju:static file="/public/plugins/Ueditor/ueditor.all.min.js"/}
  {eju:static file="/public/plugins/Ueditor/lang/zh-cn/zh-cn.js"/}
  <script type="text/javascript">
      function layer_loading(msg){
          var loading = layer.msg(
              msg+'...&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;请勿刷新页面',
              {
                  icon: 1,
                  time: 3600000, //1小时后后自动关闭
                  shade: [0.2] //0.1透明度的白色背景
              });
          //loading层
          var index = layer.load(3, {
              shade: [0.1,'#fff'] //0.1透明度的白色背景
          });

          return loading;
      }
      function show_answer(){
          $("#answer_click").hide();
          $("#answer_edit").show();
      }
      function hide_answer(){
          $("#answer_click").show();
          $("#answer_edit").hide();
      }

      window.UEDITOR_HOME_URL = "__ROOT_DIR__/public/plugins/Ueditor/";
      UE.getEditor('ask_content',{
          serverUrl :"{:url('user/Uploadify/index',array('savepath'=>'weapp'))}",
          zIndex: 999,
          initialFrameWidth: "100%", //初化宽度
          initialFrameHeight: 300, //初化高度
          focus: false, //初始化时，是否让编辑器获得焦点true或false
          maximumWords: 99999,
          removeFormatAttributes: 'class,style,lang,width,height,align,hspace,valign',//允许的最大字符数 'fullscreen',
          pasteplain:false, //是否默认为纯文本粘贴。false为不使用纯文本粘贴，true为使用纯文本粘贴
          autoHeightEnabled: false,
          toolbars: [["forecolor", "backcolor", "removeformat", "|", "simpleupload", "unlink"]],
      });

      //必须在提交前渲染编辑器；
      function ask_content() {
          //判断编辑模式状态:0表示【源代码】HTML视图；1是【设计】视图,即可见即所得；-1表示不可用
          if(UE.getEditor("ask_content").queryCommandState('source') != 0) {
              UE.getEditor("ask_content").execCommand('source'); //切换到【设计】视图
          }
      }
      function answer_submit(obj){
          if (!UE.getEditor("ask_content").getContent()) {
              layer.msg('请写下你的回答！', {time: 1500, icon: 2});
              return false;
          }
          var content = UE.getEditor("ask_content").getContent();
          layer_loading('正在处理');
          $.ajax({
              url: $(obj).data('url'),
              data: {content:content},
              type:'post',
              dataType:'json',
              success:function(res){
                  layer.closeAll();
                  if (1 == res.code) {
                      if (res.data.review) {
                          var times = 2500;
                      }else{
                          var times = 1000;
                      }
                      layer.msg(res.msg, {time: times},function(){
                          window.location.reload();
                      });
                  } else {
                      layer.msg(res.msg, {time: 1500, icon: 2});
                  }
              },
              error : function() {
                  layer.closeAll();
                  layer.alert('网络失败，请刷新页面后重试', {icon: 5, closeBtn: 0});
              }
          });
      }
      // 点赞
      function ClickLike(obj, ask_id, answer_id) {
          if ($(obj).attr('data-is_like')) {
              layer.msg('您已赞过！', {time: 1500});
              return false;
          }
          $.ajax({
              url: $(obj).data('url'),
              type: 'POST',
              dataType: 'json',
              data: {ask_id:ask_id,answer_id:answer_id},
              success: function(res) {
                  if (1 == res.code) {
                      // 设置当前用户已点赞过，用户再次点击则不需要执行ajax
                      $(obj).attr('data-is_like', true);
                      $("#like_"+answer_id).html(res.data.LikeCount);
                  } else {
                      layer.msg(res.msg, {time: 1500});
                  }

              }
          });
      }
  </script>
  {eju:answer id='field' pagesize='10'}
  <section class="pdX20 mBox">
    <div class="astTAans f15 gray-b bb">共{eju:countlist /}个回答</div>
    <div class="payasklist">
      <ul class="ul_answer">
        {eju:volist name="$field.AnswerData" id="vo"}
        <li>
          <dl class="gradePay">
            <dt>
              <a href="javascript:void(0);">
                <img class='lazyload' src="{$vo.litpic}" data-original="{$vo.litpic}">
              </a>
            </dt>
            <dd>
              <h5> {$vo.username}</h5>
            </dd>
          </dl>
          <div class="cinfo gray-0">{$vo.content}</div>
          <div class="other">
            <em> <a href="javascript:void(0);" class="zan askzan"   data-url="{$eju.field.ClickLikeUrl}"  onclick="ClickLike(this, '{$vo.ask_id}', '{$vo.id}')">{$vo.click_like}</a> </em>
            {$vo.add_time|MyDate="Y-m-d H:i:s",###}
          </div>
        </li>
        {/eju:volist}

        <li class="li-dw-p" id="askDetailMiddle" style="display:none;"></li>
        <!-- 普通答案 end -->
      </ul>

    </div>
    <div>
      <div class="page_list clearfix">
        <ul class="pagination">
          {eju:pagelist listitem="pageno,pre,next" listsize="1"/}
        </ul>
      </div>
      <div style='clear: both'></div>
    </div>
</div>
    <!--ajax加载多个答案-->
    <div class="mb8"></div>
  </section>
  {/eju:answer}
  <!-- 渐变的间距 -->
  <div class="space8jb"></div>

</div>
{eju:include file="footer.htm"/}
{eju:static file="skin/js/jquery-3.2.1.min.js" /}
{eju:static file="skin/js/swiper-3.4.2.min.js" /}
{eju:static file="skin/js/nav.js" /}
{eju:static file="skin/js/method.js" /}
{eju:static file="skin/css/layer-animate.css" /}
{eju:static file="skin/js/search_public.js" /}
<!--底部优惠开始-->
{eju:include file="youhui.htm"/}
<!--底部优惠结束-->
<!--搜索弹出层开始-->
{eju:include file="so.htm"/}
</body>
</html>